#pragma once
#include <iostream>
#include <string>

namespace MyTask
{
    class Task
    {
    private:
        int _x;
        int _y;
        char _op;

    public:
        Task(){};
        Task(int x, int y, char op)
            : _x(x), _y(y), _op(op){};

        void operator()()
        {
            Run();
        }

        void Show()
        {
            std::cout << pthread_self() << "->push a task:" << _x << _op << _y << " = ?" << std::endl;
        }

        ~Task(){};

    private:
        void Run()
        {
            int ret;
            switch (_op)
            {
            case '+':
                ret = _x + _y;
                break;
            case '-':
                ret = _x - _y;
                break;
            case '*':
                ret = _x * _y;
                break;
            case '/':
                ret = _x / _y;
                break;
            case '%':
                ret = _x % _y;
                break;
            default:
                std::cout << "error" << std::endl;
                break;
            }
            std::cout << pthread_self() << "->deal a task:" << _x << _op << _y << " = " << ret << std::endl;
        }
    };
}